<?php
namespace app\index\model;
class Yongjin extends BaseModel{
    
    
    function getYongjinAll($id){
        $uyongjin=D("uyongjin");
        return $uyongjin->where("user_id",$id)->select();
    }
    function getYongjinAll2($id,$page=1){
        $uyongjin=D("uyongjin");
        $res =  $uyongjin->where("user_id",$id)->page($page,10)->order("create_time desc")->select();
        $user = new User();
        foreach ($res as &$tmp){
            $tmp['userinfo']=$user->getUserByUserId($tmp['from_id']);
        }
        unset($tmp);
        return $res;
    }
    function getYongjinNo($id){
        $uyongjin=D("uyongjin");
        $res = $uyongjin->where("user_id",$id)->where("is_fa",1)->sum("money");
        if ($res==null){
            $res=0;
        }else{
			$res = round($res/100,2);
		}
        return $res;
    }
    
}
